import time

from unit_729.Base.Base import Base
from selenium.webdriver.common.by import By
class Page3(Base):
    # 点击登录
    login_loc = (By.XPATH,'/html/body/div[2]/div/div[1]/div/a[1]')
    def login(self):
        self.click(self.login_loc)
    # 输入用户名
    username_loc = (By.XPATH,'//*[@id="userName"]')
    def username(self):
        self.send_keys(self.username_loc,'18830857980')
    # 输入密码
    passwrod_loc = (By.XPATH,'//*[@id="password"]')
    # 点击登录
    def password(self):
        self.send_keys(self.passwrod_loc,'@123456Aa')
    login_btn_loc = (By.XPATH,'//*[@id="save"]')
    def login_btn(self):
        self.click(self.login_btn_loc)
    # 确认
    qveding_loc = (By.XPATH,'//*[@id="bindSub"]')
    def qveding(self):
        self.click(self.qveding_loc)
    search_loc = (By.XPATH,'//*[@id="wd"]')
    def search(self):
        self.send_keys(self.search_loc,'茅台')
    search_btn_loc = (By.XPATH,'/html/body/div[4]/div/div[2]/div[1]/form/input[2]')
    def searcg_btn(self):
        self.click(self.search_btn_loc)
    sp_loc =(By.XPATH,'/html/body/div[6]/div/div[2]/div[5]/ul/li[4]/div[2]/div[1]/a/img')
    def sp(self):
        self.click(self.sp_loc)
    store_nums_loc = (By.ID,'_nub')
    def store_nums(self):
        self.clear(self.store_nums_loc)
        time.sleep(2)
        self.send_keys(self.store_nums_loc, '2')
    price_loc = (By.XPATH,'//*[@id="nowPrice"]/span[1]/strong')
    def price(self):
       return self.text(self.price_loc)
    buy_loc = (By.XPATH,'//*[@id="addToCartForDetail"]')
    def buy(self):
        self.click(self.buy_loc)

    def test_jiuxian(self):
        self.open_url('https://www.jiuxian.com/')
        self.login()
        self.username()
        self.password()
        time.sleep(10)
        self.login_btn()
        time.sleep(2)
        self.qveding()
        self.search()
        time.sleep(2)
        self.searcg_btn()
        self.sp()
        self.qie()
        self.store_nums()
        self.buy()
        # time.sleep(4)







